package com.mocha;


import com.scshyzh.concurrent.ExecutorConfigManager;
import com.scshyzh.concurrent.MochaThreadPool;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;

/**
 * Manager of processors 处理器管理类<br>
 * Maintains the relationship between command and command processor through command code.
 *
 * @Author King.Song
 * @version $Id: ProcessorManager.java, v 0.1 Sept 6, 2015 2:49:47 PM tao Exp $
 */
@Slf4j
public class MochaExecutor {

    private ExecutorService defaultExecutor;


    private int minPoolSize = 32;

    private int maxPoolSize = 64;

    private int queueSize = 2000;

    private long keepAliveTime = ExecutorConfigManager.default_tp_keepalive_time();

    private MochaExecutor() {
        defaultExecutor = MochaThreadPool.buildThreadPool(minPoolSize, maxPoolSize, queueSize, keepAliveTime, "scshyzh-slow-pool");
    }

    private static final class ProcessorManagerHolder {
        static final MochaExecutor processorManager = new MochaExecutor();
    }

    public static MochaExecutor getInstance() {
        return ProcessorManagerHolder.processorManager;
    }

    public ExecutorService getDefaultExecutor() {
        return defaultExecutor;
    }

}